var code = "";
if (window.location.href.indexOf("code") != -1) {
    code = window.location.href.split("code=")[1].split("&state")[0];
}
$.ajax({
    url: Feng.ctxPath + "/integralMallWeixin/getCaseDetails",
    type: "POST",
    data: {"code": code},
    success: function (data) {
        var html = "";
        html+="<div class=\"medicalRecords\" style=\"height: 100%;font-size: 16px;\">\n" +
            "        <div class=\"integralMallHeadTop\">\n" +
            "            <div style=\"text-align: left\" onclick=\"goBackPersonalCenter()\"><span class=\"glyphicon glyphicon-menu-left\"></span></div>\n" +
            "            <div>病例记录</div>\n" +
            "            <div></div>\n" +
            "        </div>\n" +
            "        <div id=\"caseDetails-list\" style=\"height: calc(100% - 45px);overflow: auto;background: #F0F0F0;\">";
        if(data==''||data==null){
            html+="待创建";
        } else {
            for (var i = 0; i < data.length; i++) {
                if (data[i].type == 1) {
                    html += "<div class=\"caseDetails-case\">\n" +
                        "                <!--公用头部-->\n" +
                        "                <div class=\"caseDetails-case-top\">\n" +
                        "<div class=\"caseDetails-top-information\">\n" +
                        "    <img src='https://pynnn.oss-cn-hangzhou.aliyuncs.com/one/yiyatouxiang.png' alt=\"\">\n" +
                        "    <span>" + data[i].customerName + " · " + data[i].sex + "</span>\n" +
                        "</div>\n" +
                        "<div class=\"caseDetails-top-time\">" + data[i].finnallyTime1 + "</div>\n" +
                        "                </div>\n" +
                        "                <!--初诊内容-->\n" +
                        "                <div class=\"caseDetails-case-content\">\n";
                    if (data[i].zhushu != "") {
                        html += "<div class=\"caseDetails-case-item\">\n" +
                            "    <div class=\"caseDetails-item-title\">主诉</div>\n" +
                            "    <div class=\"caseDetails-item-text\">" + data[i].zhushu + "</div>\n" +
                            "</div>\n";
                    }
                    if (data[i].nowMedicalHistory != "") {
                        html += "<div class=\"caseDetails-case-item\">\n" +
                            "    <div class=\"caseDetails-item-title\">现病史</div>\n" +
                            "    <div class=\"caseDetails-item-text\">" + data[i].nowMedicalHistory + "</div>\n" +
                            "</div>\n";
                    }
                    if (data[i].beforeMedicalHistory != "") {
                        html += "<div class=\"caseDetails-case-item\">\n" +
                            "    <div class=\"caseDetails-item-title\">既往史</div>\n" +
                            "    <div class=\"caseDetails-item-text\">" + data[i].beforeMedicalHistory + "</div>\n" +
                            "</div>\n";
                    }
                    for (var j = 0; j < data[i].toothSite1List.length; j++) {
                        if (data[i].toothSite1List[j].remarks != "") {
                            html += "<div class=\"caseDetails-case-item\">\n" +
                                "    <div class=\"caseDetails-item-title\">口腔<br>检查</div>\n" +
                                "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                "        <div>牙位" + data[i].toothSite1List[j].leftUp + data[i].toothSite1List[j].rightUp
                                + data[i].toothSite1List[j].leftDown + data[i].toothSite1List[j].rightDown + "</div>\n" +
                                "        <div>" + data[i].toothSite1List[j].remarks + "</div>\n" +
                                "    </div>\n" +
                                "</div>\n";
                        }
                    }
                    for (var j = 0; j < data[i].toothSite2List.length; j++) {
                        if (data[i].toothSite2List[j].remarks != "") {
                            html += "<div class=\"caseDetails-case-item\">\n" +
                                "    <div class=\"caseDetails-item-title\">辅助<br>检查</div>\n" +
                                "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                "        <div>牙位" + data[i].toothSite2List[j].leftUp + data[i].toothSite2List[j].rightUp
                                + data[i].toothSite2List[j].leftDown + data[i].toothSite2List[j].rightDown + "</div>\n" +
                                "        <div>" + data[i].toothSite2List[j].remarks + "</div>\n" +
                                "    </div>\n" +
                                "</div>\n";
                        }
                    }
                    for (var j = 0; j < data[i].toothSite3List.length; j++) {
                        if (data[i].toothSite3List[j].remarks != "") {
                            html += "<div class=\"caseDetails-case-item\">\n" +
                                "    <div class=\"caseDetails-item-title\">诊断</div>\n" +
                                "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                "        <div>牙位" + data[i].toothSite3List[j].leftUp + data[i].toothSite3List[j].rightUp
                                + data[i].toothSite3List[j].leftDown + data[i].toothSite3List[j].rightDown + "</div>\n" +
                                "        <div>" + data[i].toothSite3List[j].remarks + "</div>\n" +
                                "    </div>\n" +
                                "</div>\n";
                        }
                    }
                    for (var j = 0; j < data[i].toothSite4List.length; j++) {
                        if (data[i].toothSite4List[j].remarks != "") {
                            html += "<div class=\"caseDetails-case-item\">\n" +
                                "    <div class=\"caseDetails-item-title\">治疗<br>计划</div>\n" +
                                "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                "        <div>牙位" + data[i].toothSite4List[j].leftUp + data[i].toothSite4List[j].rightUp
                                + data[i].toothSite4List[j].leftDown + data[i].toothSite4List[j].rightDown + "</div>\n" +
                                "        <div>" + data[i].toothSite4List[j].remarks + "</div>\n" +
                                "    </div>\n" +
                                "</div>\n";
                        }
                    }
                    for (var j = 0; j < data[i].toothSite5List.length; j++) {
                        if (data[i].toothSite5List[j].remarks != "") {
                            html += "<div class=\"caseDetails-case-item\">\n" +
                                "    <div class=\"caseDetails-item-title\">处置</div>\n" +
                                "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                "        <div>牙位" + data[i].toothSite5List[j].leftUp + data[i].toothSite5List[j].rightUp
                                + data[i].toothSite5List[j].leftDown + data[i].toothSite5List[j].rightDown + "</div>\n" +
                                "        <div>" + data[i].toothSite5List[j].remarks + "</div>\n" +
                                "    </div>\n" +
                                "</div>\n";
                        }
                    }
                    if (data[i].doctorAdvice != "") {
                        html += "<div class=\"caseDetails-case-item\">\n" +
                            "    <div class=\"caseDetails-item-title\">医嘱</div>\n" +
                            "    <div class=\"caseDetails-item-text\">" + data[i].doctorAdvice + "</div>\n" +
                            "</div>\n";
                    }
                    html += "</div>\n" +
                        "</div>";
                } else if (data[i].type == 2) {
                    html += "<div class=\"caseDetails-case\">\n" +
                        "                <!--公用头部-->\n" +
                        "                <div class=\"caseDetails-case-top\">\n" +
                        "<div class=\"caseDetails-top-information\">\n" +
                        "    <img src='https://pynnn.oss-cn-hangzhou.aliyuncs.com/one/yiyatouxiang.png' alt=\"\">\n" +
                        "    <span>" + data[i].customerName + " · " + data[i].sex + "</span>\n" +
                        "</div>\n" +
                        "<div class=\"caseDetails-top-time\">" + data[i].finnallyTime1 + "</div>\n" +
                        "                </div>\n" +
                        "                <!--复诊内容-->\n" +
                        "                <div class=\"caseDetails-case-content\">\n";
                    if (data[i].zhushu != "") {
                        html += "<div class=\"caseDetails-case-item\">\n" +
                            "    <div class=\"caseDetails-item-title\">复诊</div>\n" +
                            "    <div class=\"caseDetails-item-text\">" + data[i].zhushu + "</div>\n" +
                            "</div>\n";
                        for (var j = 0; j < data[i].toothSite1List.length; j++) {
                            if (data[i].toothSite1List[j].remarks != "") {
                                html += "<div class=\"caseDetails-case-item\">\n" +
                                    "    <div class=\"caseDetails-item-title\">口腔<br>检查</div>\n" +
                                    "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                    "        <div>牙位" + data[i].toothSite1List[j].leftUp + data[i].toothSite1List[j].rightUp
                                    + data[i].toothSite1List[j].leftDown + data[i].toothSite1List[j].rightDown + "</div>\n" +
                                    "        <div>" + data[i].toothSite1List[j].remarks + "</div>\n" +
                                    "    </div>\n" +
                                    "</div>\n";
                            }
                        }
                        for (var j = 0; j < data[i].toothSite2List.length; j++) {
                            if (data[i].toothSite2List[j].remarks != "") {
                                html += "<div class=\"caseDetails-case-item\">\n" +
                                    "    <div class=\"caseDetails-item-title\">辅助<br>检查</div>\n" +
                                    "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                    "        <div>牙位" + data[i].toothSite2List[j].leftUp + data[i].toothSite2List[j].rightUp
                                    + data[i].toothSite2List[j].leftDown + data[i].toothSite2List[j].rightDown + "</div>\n" +
                                    "        <div>" + data[i].toothSite2List[j].remarks + "</div>\n" +
                                    "    </div>\n" +
                                    "</div>\n";
                            }
                        }
                        for (var j = 0; j < data[i].toothSite3List.length; j++) {
                            if (data[i].toothSite3List[j].remarks != "") {
                                html += "<div class=\"caseDetails-case-item\">\n" +
                                    "    <div class=\"caseDetails-item-title\">诊断</div>\n" +
                                    "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                    "        <div>牙位" + data[i].toothSite3List[j].leftUp + data[i].toothSite3List[j].rightUp
                                    + data[i].toothSite3List[j].leftDown + data[i].toothSite3List[j].rightDown + "</div>\n" +
                                    "        <div>" + data[i].toothSite3List[j].remarks + "</div>\n" +
                                    "    </div>\n" +
                                    "</div>\n";
                            }
                        }
                        for (var j = 0; j < data[i].toothSite4List.length; j++) {
                            if (data[i].toothSite4List[j].remarks != "") {
                                html += "<div class=\"caseDetails-case-item\">\n" +
                                    "    <div class=\"caseDetails-item-title\">治疗<br>计划</div>\n" +
                                    "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                    "        <div>牙位" + data[i].toothSite4List[j].leftUp + data[i].toothSite4List[j].rightUp
                                    + data[i].toothSite4List[j].leftDown + data[i].toothSite4List[j].rightDown + "</div>\n" +
                                    "        <div>" + data[i].toothSite4List[j].remarks + "</div>\n" +
                                    "    </div>\n" +
                                    "</div>\n";
                            }
                        }
                        for (var j = 0; j < data[i].toothSite5List.length; j++) {
                            if (data[i].toothSite5List[j].remarks != "") {
                                html += "<div class=\"caseDetails-case-item\">\n" +
                                    "    <div class=\"caseDetails-item-title\">处置</div>\n" +
                                    "    <div class=\"caseDetails-item-text caseDetails-item-tooth\">\n" +
                                    "        <div>牙位" + data[i].toothSite5List[j].leftUp + data[i].toothSite5List[j].rightUp
                                    + data[i].toothSite5List[j].leftDown + data[i].toothSite5List[j].rightDown + "</div>\n" +
                                    "        <div>" + data[i].toothSite5List[j].remarks + "</div>\n" +
                                    "    </div>\n" +
                                    "</div>\n";
                            }
                        }
                        if (data[i].doctorAdvice != "") {
                            html += "<div class=\"caseDetails-case-item\">\n" +
                                "    <div class=\"caseDetails-item-title\">医嘱</div>\n" +
                                "    <div class=\"caseDetails-item-text\">" + data[i].doctorAdvice + "</div>\n" +
                                "</div>\n";
                        }
                        html += "</div>\n" +
                            "</div>";
                    }
                }
            }
        }
        html+=" </div>\n" +
            "    </div>";
        $("#caseDetails").html(html);
    },
    error: function (data) {

    }
});